
from selenium.webdriver.common.by import By


class CrmHomePageLocator:
    # crm首页导航栏按钮
    navigation_btn_loc = \
        (By.XPATH, '//button[@class="mat-focus-indicator mat-icon-button mat-button-base td-layout-menu-button"]')
    # 学生服务  contains(text(),'11')  contains(.,'11')
    list_stu_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"学生服务")]')
    # 班级管理
    list_class_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"班级管理")]')
    # 订单管理
    list_order_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"订单管理")]')
    # 用户添加
    list_user_add_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"用户添加")]')


class CrmClassTemplateLocator:
    """crm-班级管理-模板管理"""
    # 模板管理
    list_template_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"模板管理")]')
    create_temp_btn_loc = (By.XPATH, "//button[contains(.,'新建模板')]")
    # 添加
    add_loc = (By.XPATH, "//button[contains(.,'添加')]")

    # ### 添加-选择课程弹层 ####
    course_name_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//input[@placeholder='课程名称']")
    search_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//button[contains(.,'搜索')]")
    # checkbox_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//div[@class='td-data-table-cell-content-wrapper']//span[contains(.,'UI创建课程1640317203')]/../../../td/div/mat-pseudo-checkbox")
    # 根据课程名称确定勾选框
    checkbox_loc_lst = [By.XPATH, "//td[contains(.,'{}')]/..//mat-pseudo-checkbox"]
    # 确定
    confirm_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//button[contains(.,'确定')]")
    # confirm_loc = (By.XPATH, "//div[@class='cdk-global-overlay-wrapper']//span[text()='确定']/..")
    # ### 添加-选择课程弹层 ####

    # 确定班级渠道
    class_channel_loc = (By.XPATH, "//mat-select[@placeholder='确定班级渠道']")
    channel_input_loc = (By.XPATH, "//input[contains(@class,'select-input-search')]")
    test_channel_loc = (By.XPATH, "//span[@class='mat-option-text' and text()='测试渠道']")
    # 价格信息
    # 免费课时数
    free_class_hours_loc = (By.XPATH, "//input[@placeholder='免费课时数']")
    # 上课平台Class platform
    # 直播班容
    class_capacity_loc = (By.XPATH, "//input[@placeholder='直播班容']")
    # 班级上课时间设置
    class_number_loc = (By.XPATH, "//input[@placeholder='开班量']")
    # 价格信息
    # 课时售价
    # //div[@class='ng-star-inserted' and contains(.,'课时售价')]/following-sibling::div[1]/input[@class='ng-untouched ng-pristine ng-valid'][1]
    price_loc = (By.XPATH, "//input[@class='ng-untouched ng-pristine ng-valid'][1]")
    price_loc = (By.XPATH, "//div[@class='ng-star-inserted' and contains(.,'课时售价')]/following-sibling::div[1]/input[contains(@class,'ng-valid')][1]")
    # 显示价
    display_price = (By.XPATH, "//input[@class='ng-untouched ng-pristine ng-valid'][2]")
    display_price = (By.XPATH, "//div[@class='ng-star-inserted' and contains(.,'课时售价')]/following-sibling::div[1]/input[contains(@class,'ng-valid')][2]")
    # 合同价价
    contract_price = (By.XPATH, "//input[@class='ng-untouched ng-pristine ng-valid'][3]")
    contract_price = (By.XPATH, "//div[@class='ng-star-inserted' and contains(.,'课时售价')]/following-sibling::div[1]/input[contains(@class,'ng-valid')][3]")
    # 提交
    submit_confirm_loc = (By.XPATH, "//button[@class='mat-focus-indicator mat-button mat-button-base ng-star-inserted']")
    submit_confirm_loc = (By.XPATH, "//span[@class='mat-button-wrapper' and text()='确定']")
    # 创建模版--模版详情页-确定按钮
    temp_detail_submit_confirm_loc = (By.XPATH, "//div[@class='td-layout-manage-list-main']//button[contains(.,'确定')]")

    # 模版ID输入框
    temp_id_loc = (By.XPATH, "//input[@placeholder='模板ID']")
    # 搜索
    temp_search_loc = (By.XPATH, "//button[contains(.,'搜索')]")
    # 列表编辑
    table_edit_loc = (By.XPATH, "//mat-icon[@mattooltip='查看详情']")
    # 模版列表编辑页-开班量
    amount_of_class_loc = (By.XPATH, "//input[@placeholder='开班量']")
    create_class_loc = (By.XPATH, "//button[contains(.,'开班')]")

    temp_search_loc = (By.XPATH, "//button[contains(.,'搜索')]")
    td_temp_id_loc = (By.XPATH, "//tr[1]/td[6]")
    td_temp_name_loc = (By.XPATH, "//tr[1]/td[7]")


class ClassManagementLocator:
    """班级管理主页"""
    # 重置
    reset_loc = (By.XPATH, "//button[contains(.,'重置')]")
    # 科目
    select_subject_loc = (By.XPATH, "//mat-select[@placeholder='科目']")
    subject_loc = (By.XPATH, "//span[text()='中文']")
    select_condition_loc = (By.XPATH, "//div[contains(@class,'push-bottom')]/mat-select[1]/div")
    temp_id_loc = (By.XPATH, "//span[@class='mat-option-text' and text()=' 模板ID ']")
    input_temp_id_loc = (By.XPATH, "//div[contains(@class,'push-bottom')]/mat-form-field[1]//input")
    search_loc = (By.XPATH, "//button[contains(.,'搜索')]")
    checkbox_loc = (By.XPATH, "//td/div/mat-pseudo-checkbox")
    put_loc = (By.XPATH, "//button[contains(.,'上架')]")
    confirm_loc = (By.XPATH, "//button[contains(.,'确定')]")
    class_id_loc = (By.XPATH, "//tr/td[7]")


class CrmUserAddLocator:
    """crm-用户添加页"""
    #  国外用户查询 导航
    list_foreign_user_query_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"国外用户查询")]')
    #  用户添加 导航 （国内）
    list_domestic_user_add_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"用户添加")]', 1)
    list_domestic_user_add_loc = (By.XPATH, '//div[@class="mat-drawer-inner-container ng-tns-c142-3"]//div[@class="mat-list-item-content" and contains(.,"用户添加")]')

    # 输入手机号（国外用户查询页）
    user_input_loc = (By.XPATH, "//input[contains(@class,'ng-invalid')]")
    # 输入手机号（国内用户添加页）
    domestic_user_input_loc = (By.XPATH, '//input[@placeholder="手机号"]')
    # 创建用户
    create_user_loc = (By.XPATH, "//div[@class='pad-sm push-bottom-md' and contains(.,'请选择获客渠道创建')]")
    # 搜索
    btn_search_loc = (By.XPATH, "//button[contains(@class,'search')]")
    # 下单
    btn_PlaceAnOrder_loc = (By.XPATH, "//button[contains(.,'下单')]")
    # 输入班级id（必须科目为中文的班级）
    input_class_loc = (By.XPATH, "//input[@placeholder='请输入班级id']")
    # 添加班级
    mat_add_loc = (By.XPATH, "//mat-icon[@mattooltip='添加']")
    # 确定
    btn_confirm_loc = (By.XPATH, "//span[text()='确定']/..")
    # 是否免支付
    no_pay_loc = (By.XPATH, "//div[contains(text(),' 是否免支付：')]/mat-checkbox//input")
    no_pay_loc = (By.XPATH, "//div[contains(text(),' 是否免支付：')]/mat-checkbox/label/div")
    # 回执单
    receipt_loc = (By.XPATH, "//input[@placeholder='（必填）请录入回执单号']")
    # 订单说明
    order_description_loc = (By.XPATH, "//textarea[@placeholder='订单说明']")
    # 提交
    btn_submit_loc = (By.XPATH, "//button[contains(., '提交')]")
    # wait_div
    wait_div_loc = (By.XPATH, "//div[@class='mat-padding ng-star-inserted']")

    # ###########创建国内用户弹层-start###########
    # 获客渠道一
    obtain_channel_1_loc = (By.XPATH, "//mat-select[@placeholder='获客渠道一']")
    channel_1_name_loc = [By.XPATH, "//span[@class='mat-option-text' and text()='{}']"]
    # 获客渠道一
    obtain_channel_2_loc = (By.XPATH, "//mat-select[@placeholder='获客渠道二']")
    channel_2_name_loc = [By.XPATH, "//span[@class='mat-option-text' and text()='{}']"]
    # 家长姓名
    parent_name_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//input[@placeholder='家长姓名：']")
    # 与孩子关系
    rwc_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='与孩子关系：' ]")
    rwc_fatherOrmother_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[@class='mat-option-text' and text()='{}']"]
    province_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='省']")
    city_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='市']")
    county_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='区']")
    province_name_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[@class='mat-option-text' and text()='{}']"]
    city_name_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[@class='mat-option-text' and text()='{}']"]
    county_name_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[@class='mat-option-text' and text()='{}']"]
    created_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//button[contains(.,'创建')]")
    # 添加学员
    add_student_loc = (By.XPATH, "//button[contains(.,'添加学员')]")
    # 学员名字
    student_name_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//input[@placeholder='中文姓名：']")
    student_English_name_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//input[@placeholder='英文姓名：']")
    # 性别
    gender_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='性别：']")
    sex_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[text()='{}']"]
    age_select_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//mat-select[@placeholder='年龄：']")
    age_loc = [By.XPATH, "//div[@class='cdk-overlay-pane']//span[text()='{}']"]
    # 确定
    determine_loc = (By.XPATH, "//div[@class='cdk-overlay-pane']//button[contains(.,'确定')]")
    # ###########创建国内用户弹层-end#############


class CrmOrderRecordLocator:
    """订单记录"""
    #  订单记录 导航
    list_OrderRecord_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"订单记录")]')
    # 审核状态
    audit_status_loc = (By.XPATH, "//mat-select[@aria-label='审核状态']")
    # 待审核
    await_audit_loc = (By.XPATH, "//span[text()='待审核']")
    # 家长手机号
    parent_mobile_loc = (By.XPATH, "//input[@placeholder='家长手机号']")
    # 订单搜索
    order_search_loc = (By.XPATH, "//button[contains(.,'搜索')]")
    # 重置
    reset_loc = (By.XPATH, "//button[contains(.,'重置')]")

    # 订单编号, 通过家长手机号获取订单号
    order_id_loc = [By.XPATH, "//span[@class='ng-star-inserted' and contains(.,'{mobile}')]/../../../td[3]//span"]

    #  订单审核 导航
    list_OrderReview_loc = (By.XPATH, '//div[@class="mat-list-item-content" and contains(.,"订单审核")]')
    # 显示全部订单
    all_order_loc = (By.XPATH, "//span[contains(.,'显示全部订单')]/../div")
    all_order_loc1 = (By.XPATH, "//span[contains(.,'显示全部订单')]/../..")
    # 订单编号输入框
    input_OrderId_loc = (By.XPATH, "//input[@placeholder='订单编号']")

    # 通过订单编号确认勾选框
    OrderToCheckbox_loc = [By.XPATH, "//span[contains(.,'{orderId}')]/../../..//mat-pseudo-checkbox"]
    # 批量通过
    btn_pass_loc = (By.XPATH, "//button[contains(.,'批量通过')]")
    # toast
    toast_loc = (By.XPATH, "//div[@class='cdk-overlay-container']")


class CrmQuitClassLocator:
    """退班相关页面定位"""
    # 班级信息
    class_info_loc = (By.XPATH, "//span[contains(.,'班级信息')]")
    # 退班按钮
    quit_class_loc = (By.XPATH, "//span[contains(text(),'退班')]")
    # 勾选需要退班课时
    lesson_checkbox_layout = (By.XPATH, "//label[@class='mat-checkbox-layout']")
    # 弹窗下拉
    js_loc = "document.getElementsByClassName('cdk-overlay-pane')[0].getElementsByTagName('mat-dialog-container')[0].scrollTo(0, 1000)"
    # 弹窗-教材机会状态选择框
    textbook_status_loc = (By.XPATH, "//span[contains(text(), '教材回寄状态')]")
    # 选择还未寄出
    no_send_loc = (By.XPATH, "//span[contains(text(), '还未寄出')]")
    # 退班备注
    remarks_loc = (By.XPATH, "//textarea[@placeholder='退班备注']")
    # 确认
    confirm_loc = (By.XPATH, "//span[@class='mat-button-wrapper' and text()='确认']/..")
    confirm_loc = (By.XPATH, "//button[contains(., '确认')]")

    # 订单管理-导航-退班审核
    quit_class_review = (By.XPATH, "//div[@class='mat-list-item-content' and contains(., ' 退班审核')]")
    # 显示全部班级-勾选
    dis_all_loc = (By.XPATH, "//span[@class='mat-checkbox-label' and contains(.,'显示全部班级')]")
    # 输入家长手机号
    parent_mobile_loc = (By.XPATH, "//input[@placeholder='搜索家长手机号']")
    # 列表勾选框
    checkbox_loc = [By.XPATH, "//td[contains(.,'{}')]/../td//mat-pseudo-checkbox"]
    # 批量审核通过
    pass_loc = (By.XPATH, "//button[contains(.,'批量审核通过')]")
    # toast提示
    toast_loc = (By.XPATH, "//div[@class='cdk-overlay-container' and contains(.,'成功')]")
    toast_loc = (By.XPATH, "//div[@class='cdk-overlay-container']")

    # 国外退班
    # 手机号下拉框
    mobile_select_loc = (By.XPATH, "//div[contains(., '手机号') and contains(@class, 'mat-select-value')]/..")
    # 下拉选项-邮箱
    mail_lco = (By.XPATH, "//span[@class='mat-option-text' and contains(.,'邮箱')]")
    # 邮箱输入框
    mail_input_loc = (By.XPATH, "//div[contains(@class,'mat-form-field-wrapper') and contains(.,邮箱)]/../../mat-form-field[2]//input[1]")
    # 国外学员退班通过班级编号找到退班按钮, 填入班级编号
    class_id_to_quit_loc = [By.XPATH, "//td[contains(.,'{}')]/../td[contains(.,'退班')]//span[text()='退班']"]
    # 勾选国外退班勾选框
    foreign_checkbox_loc = (By.XPATH, "//input[@type='checkbox']/..")

    # 审核
    # 是否特殊渠道选择
    is_special_channel_loc = (By.XPATH, "//mat-select[@placeholder='是否特殊退班']")
    all_channel_loc = (By.XPATH, "//span[text()='所有']")
    # 退班班级编号
    quit_class_id_input_loc = (By.XPATH, "//input[@placeholder='退班班级编号']")
    # 勾选
    foreign_quit_checkbox_loc = (By.XPATH, "//td//mat-pseudo-checkbox")
